package com.qzsf.backend.controller;

import com.qzsf.backend.common.Result;
import com.qzsf.backend.entity.EventType;
import com.qzsf.backend.service.EventTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
 * @Author: Dennis Chen
 * @CreateTime: 2024/10/31 10:13 周四
 * @Email 1429278462@qq.com
 * @Remark 活动分类控制器
 * @Version 1.0
 */
@RestController
@RequestMapping("/eventTypes")
public class EventTypeController {
    @Autowired
    private EventTypeService eventTypeService;
    @GetMapping
    public Result getAllEventType(@RequestParam(required = false) String type,@RequestParam int pageNo, @RequestParam int pageSize){
        return eventTypeService.getAllEventTypes(type,pageNo,pageSize);
    }

    @GetMapping("/{id}")
    public Result getEventTypeById(@PathVariable int id){
        return eventTypeService.getEventTypeById(id);
    }

    @PostMapping
    public Result createEventType(@RequestBody EventType eventType){
        return eventTypeService.createEventType(eventType);
    }

    @PutMapping
    public Result updateEventType(@RequestBody EventType eventType){
        return eventTypeService.updateEventType(eventType);
    }

    @DeleteMapping("/{id}")
    public Result deleteEventType(@PathVariable int id){
        return eventTypeService.deleteEventType(id);
    }
}
